/**
 * Created by Jie on 2017/2/4.
 */
var express = require('express');
var router = express.Router();
var session = require('express-session');

var data = require('../util/result');
var common = require('../controller/publicController');
var users = require('../controller/core/usersController');

router.get('/', function(req, res, next) {
    common.index(req,res);
});
router.post('/', function(req, res, next) {
    var uCode = req.body.yzm;
    var sCode = req.session.code;
    console.log(req.session.code)
    if(uCode != sCode){
        res.json(data.result(1,"验证码错误"));
        return;
    }
    users.login(req,res);
});
router.get('/code', function(req, res, next) {
    common.code(req,res)
});
router.get('/auth', function(req, res, next) {
    common.auth(req,res)
});
router.get('/out', function(req, res, next) {
    req.session.user = {};
    res.json({error:0,message:'ok'});
});
module.exports = router;

